#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
'''
@File    :   psqi_eval_param.py
@Time    :   2020/11/27
@Author  :   wenke wang
@Version :   1.0
@Desc    :   PSQI睡眠评估参数
'''

# here put the import lib
from datetime import datetime, timedelta

class PsqiEvalParam():
    """
    PSQI睡眠评估参数
    """
    def __init__(self, sleeping_time, fell_asleep, get_up_time, fact_sleeping_hours, not_fell_asleep_30min, wake_in_night, to_restroom_in_night, \
            difficult_breathing, cough_or_snoring, feeling_cold, feeling_hot, nightmare, pain, others, sleeping_quality, \
            sleeping_pills, sleepy, anenergia):
        self.__sleeping_time = sleeping_time
        self.__fell_asleep = int(fell_asleep)
        self.__get_up_time = get_up_time
        self.__on_bed_hours = self.__diff_hours(sleeping_time, get_up_time)
        self.__fact_sleeping_hours = str(fact_sleeping_hours)
        self.__not_fell_asleep_30min = int(not_fell_asleep_30min)
        self.__wake_in_night = int(wake_in_night)
        self.__to_restroom_in_night = int(to_restroom_in_night)
        self.__difficult_breathing = int(difficult_breathing)
        self.__cough_or_snoring = int(cough_or_snoring)
        self.__feeling_cold = int(feeling_cold)
        self.__feeling_hot = int(feeling_hot)
        self.__nightmare = int(nightmare)
        self.__pain = int(pain)
        self.__others = int(others)
        self.__sleeping_quality = int(sleeping_quality)
        self.__sleeping_pills = int(sleeping_pills)
        self.__sleepy = int(sleepy)
        self.__anenergia = int(anenergia)

    def __diff_hours(time1, time2):
        t1 = datetime.strptime(time1, "%H:%M")
        t2 = datetime.strptime(time2, "%H:%M")
        t2 = t2 + timedelta(days=1)
        delta = t2 - t1
        hours = (Decimal(delta.seconds) / Decimal(3600)).quantize(Decimal("0"))
        return hours


    @property
    def sleeping_time(self):
        """
        晚上睡觉时间(24小时制，格式：%H:%M)
        """
        return self.__sleeping_time
    @sleeping_time.setter
    def sleeping_time(self, val):
        self.__sleeping_time = val
        self.__on_bed_hours = self.__diff_hours(val, self.__get_up_time)

    @property
    def fell_asleep(self):
        """
        从上床到入睡需要时长(min)
        """
        return self.__fell_asleep
    @fell_asleep.setter
    def fell_asleep(self, val):
        self.__fell_asleep = int(fell_asleep)

    @property
    def get_up_time(self):
        """
        早上起床时间(24小时制，格式：%H:%M)
        """
        return self.__get_up_time
    @get_up_time.setter
    def get_up_time(self, val):
        self.__get_up_time = val
        self.__on_bed_hours = self.__diff_hours(self.__sleeping_time, val)

    @property
    def on_bed_hours(self):
        """
        床上时间(小时)
        """
        return self.__on_bed_hours

    @property
    def fact_sleeping_hours(self):
        """
        每夜实际睡眠时长(小时)
        """
        return self.__fact_sleeping_hours
    @fact_sleeping_hours.setter
    def fact_sleeping_hours(self, val):
        self.__fact_sleeping_hours = str(val)

    @property
    def not_fell_asleep_30min(self):
        """
        入睡困难 (30分钟不能入睡)
        """
        return self.__not_fell_asleep_30min
    @not_fell_asleep_30min.setter
    def not_fell_asleep_30min(self, val):
        self.__not_fell_asleep_30min = int(val)

    @property
    def wake_in_night(self):
        """
        夜间易醒或者早醒
        """
        return self.__wake_in_night
    @wake_in_night.setter
    def wake_in_night(self, val):
        self.__wake_in_night = int(val)

    @property
    def to_restroom_in_night(self):
        """
        夜间去厕所
        """
        return self.__to_restroom_in_night
    @to_restroom_in_night.setter
    def to_restroom_in_night(self, val):
        self.__to_restroom_in_night = int(val)

    @property
    def difficult_breathing(self):
        """
        呼吸不畅
        """
        return self.__difficult_breathing
    @difficult_breathing.setter
    def difficult_breathing(self, val):
        self.__difficult_breathing = int(val)

    @property
    def cough_or_snoring(self):
        """
        咳嗽或鼾声高
        """
        return self.__cough_or_snoring
    @cough_or_snoring.setter
    def cough_or_snoring(self, val):
        self.__cough_or_snoring = int(val)
    
    @property
    def feeling_cold(self):
        """
        感觉冷
        """
        return self.__feeling_cold
    @feeling_cold.setter
    def feeling_cold(self, val):
        self.__feeling_cold = int(feeling_cold)

    @property
    def feeling_hot(self):
        """
        感觉热
        """
        return self.__feeling_hot
    @feeling_hot.setter
    def feeling_hot(self, val):
        self.__feeling_hot = int(val)
    
    @property
    def nightmare(self):
        """
        做噩梦
        """
        return self.__nightmare
    @nightmare.setter
    def nightmare(self, val):
        self.__nightmare = int(val)

    @property
    def pain(self):
        """
        疼痛不适
        """
        return self.__pain
    @pain.setter
    def pain(self, val):
        self.__pain = int(val)

    @property
    def others(self):
        """
        其它影响睡眠的情况
        """
        return self.__others
    @others.setter
    def others(self, val):
        self.__others = int(val)

    @property
    def sleeping_quality(self):
        """
        近1个月，总的来说，您认为己的睡眠质量
        """
        return self.__sleeping_quality
    @sleeping_quality.setter
    def sleeping_quality(self, val):
        self.__sleeping_quality = int(val)

    @property
    def sleeping_pills(self):
        """
        近1个月，您用药物催眠的情况
        """
        return self.__sleeping_pills
    @sleeping_pills.setter
    def sleeping_pills(self, val):
        self.__sleeping_pills = int(val)

    @property
    def sleepy(self):
        """
        近1个月，您常感到困倦吗
        """
        return self.__sleepy
    @sleepy.setter
    def sleepy(self, val):
        self.__sleepy = int(val)

    @property
    def anenergia(self):
        """
        近1个月，您做事情的精力不足吗
        """
        return self.__anenergia
    @anenergia.setter
    def anenergia(self, val):
        self.__anenergia = int(val)